package com.javaear.beangenerator;

import com.javaear.beangenerator.render.JaxbRender;
import com.javaear.beangenerator.render.JsonRender;
import com.javaear.beangenerator.render.MysqlRender;
import com.javaear.beangenerator.render.Render;

/**
 * just singleton
 *
 * @author aooer
 */
final class RenderHolder {

    private Render render;

    /***************
     * select reander
     *****************/
    public Render mysqlRender() {
        return render instanceof MysqlRender ? render : new MysqlRender();
    }

    public Render jsonRender(String dataStr) {
        return render instanceof JsonRender ? render : new JsonRender(dataStr);
    }

    public Render jaxbRender() {
        return render instanceof JaxbRender ? render : new JaxbRender();
    }

    /***************
     * singleton
     ****************/

    private static class SingleHolder {
        private static RenderHolder INSTANCE = new RenderHolder();
    }

    public static RenderHolder getInstance() {
        return SingleHolder.INSTANCE;
    }

    private RenderHolder() {
    }
}
